<?xml version="1.0" encoding="UTF-8" ?>
<%@ page
	contentType="text/html;charset=UTF-8"
	pageEncoding="UTF-8"
	import="fr.utbm.gi.in56.error.ErrorType"
%>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
        <link rel="stylesheet" media="screen" type="text/css" title="Style" href="style.css" />
        <script type="text/javascript" src="ressources/scripts/filterList.js"></script>
        <title>L'Entre-Pot</title>
    </head>
    <body>
        <div id ="container">
            <jsp:directive.include file="header.jsp"/>
            <jsp:directive.include file="topMenu.jsp"/>
            <div id="core">
            	<h2 align="center">Écrire un message</h2>
            	<div id="defaultForm">
            		<% ErrorType error = (ErrorType)request.getAttribute( "sendMessageError" );%>
					<%
						if( error != null )
						{
					%>
							<div id="error">
							    <%= error.getErrorMessage() %>
							</div>
					<%
						}
					%>
					<%
						String recipient	= (String)request.getAttribute( "recipient" );
						Integer adIdInteger	= (Integer)request.getAttribute( "adId" );
						String adTitle		= (String)request.getAttribute( "adTitle" );
						String adType		= (String)request.getAttribute( "adType" );
						String msgType		= (String)request.getAttribute( "msgType" );
					%>
            		<form method="post" action="SendMessageServlet" name="sendMessage">
            			<%/*<div id="defaultFormEntry">
							<label for="recipient">Destinataire</label>
							<input type="text" name="recipient" id="recipient" onkeyup="selectFilter('select-list', this.value)" />
							<select id="select-list" size="1" style="width:200px">
							  <option>snake23</option>
							  <option>Adrien</option>
							  <option>Un autre connard</option>
							</select>
						</div>*/%>
						<div id="defaultFormEntry">
							<label for="recipient">Destinataire :</label>
							<%
								if ( ( recipient != null ) && ( !recipient.isEmpty() ) )
								{
							%>
									<input type="text" name="recipient" id="recipient" readonly="true" value="<%= recipient %>"/>
							<%	
								}
								else
								{
							%>
									<input type="text" name="recipient" id="recipient"/>
							<%
								}
							%>
						</div>
						<div id="defaultFormEntry">
							<input type="hidden" name="adId" value="<%= ( adIdInteger != null ) ? adIdInteger.intValue() : 0 %>">
						</div>
						<div id="defaultFormEntry">
							<label for="ad">Annonce concernée :</label>
								<input type="text" name="adTitle" id="adTitle" readonly="true" value="<%= ( adTitle != null ) ? adTitle : "" %>"/>
						</div>
						<div id="defaultFormEntry">
							<input type="hidden" name="adType" value="<%= ( adType != null ) ? adType : "" %>">
						</div>
						<div id="defaultFormEntry">
							<input type="hidden" name="msgType" value="<%= ( msgType != null ) ? msgType : "" %>">
						</div>
						<%
							String subject = (String)request.getAttribute( "subject" );
						%>
						<div id="defaultFormEntry">
							<label for="object">Objet du message :</label>
							<input type="text" name="subject" id="subject" maxlength="50" value="<%= ( subject != null ) ? subject : "" %>"/>
						</div>
						<%
							String message = (String)request.getAttribute( "message" );
						%>
						<div id="defaultFormEntry">	
							<label for="message">Message :</label>
							<textarea cols="80" rows="6" name="message" id="description" message="500"><%= ( message != null ) ? message : "" %></textarea>
						</div>
						<div id="defaultFormEntry">
							<p class="center">
							<input type="submit" value="Envoyer" name="post"/>
							</p>
						</div>
					</form>
				</div>
			</div>
			
			<jsp:directive.include file="footer.jsp"/>
        </div>
    </body>
</html>